package com.heima.search.service.impl;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.search.service.ApAssociateWordsService;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApAssociateWordsServiceImpl implements ApAssociateWordsService {

/*    @Autowired
    RestHighLevelClient restHighLevelClient;*/

    @Override
    public ResponseResult findAssociate(UserSearchDto userSearchDto) {
        if(StringUtils.isBlank(userSearchDto.getSearchWords())){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }

/*        SearchRequest searchRequest = new SearchRequest(APP_INFO_ARTICLE);
        FuzzyQueryBuilder queryBuilder = new FuzzyQueryBuilder("title",userSearchDto.getSearchWords());

        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
        sourceBuilder.query(queryBuilder);
        searchRequest.source(sourceBuilder);

        try {
            SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        return ResponseResult.okResult();
    }
}